home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / BASIC / LIB / EVENTSHELL / EXTENSION / OLELib (.txt) < prev    next >
RISC OS BBC BASIC V Source  |  1995-10-18  |  6KB  |  146 lines

  1.  Module OLE
  2.  -----------------------------------------------------------------------
  3.  OLE Handling Routines (version 1.03 18-Oct-95)
  4.  -----------------------------------------------------------------------
  5.  Public Methods Supported:
  6.    FN_shell_OLELib_Init            Initialises module
  7.    PROCshell_OLELinkFile           Sets up the OLE link for the specified file
  8.    PROCshell_OLEDeLinkFile         Breaks the link to the file
  9.    PROCshell_OLEScanLinkedFiles    Called during the null event poll
  10.    PROCshell_OLEGetNrOfLinkedFiles Returns nr of files currently linked
  11.    PROCshell_OLEInProgress         Returns TRUE if OLE in progress
  12.  Responses to events raised by other modules
  13.    PROCshell_DoOLEHandling
  14.  REM Private Methods Supported:
  15.    None
  16.  *|Start FN_shell_OLELib_Init
  17. _shell_OLELib_Init
  18.  Set up global constants for this module
  19. OLE_RecLength%   = 16
  20. OLE_EndOfData%   = -1
  21.  Set up global variables for this module
  22. G_OLE_DataBlock% = 0
  23. G_OLE_NrOfFiles% = 0
  24.  Format of data block is:
  25.    +00 ptr to filename
  26.    +04 ptr to FN name
  27.    +08 low word file datestamp
  28.    +12 hi  word file datestamp (not used at the moment)
  29.    ...
  30.    +nn
  31.    +nn
  32.    +nn
  33. shell_ExReg_OLELib_Loaded
  34. *|Stop FN_shell_OLELib_Init
  35. 5!*|Start PROCshell_OLELinkFile
  36. shell_OLELinkFile( file_name$, user_FN$ )
  37.  loc_newrecord%
  38.  G_OLE_DataBlock% = 0 
  39.  First time it has been called, so initialise OLE data block...
  40. <@  G_OLE_DataBlock% = 
  41. shell_HeapBlockFetch( OLE_RecLength% )
  42.  Initialise data block (write end of data marker words)
  43. >*  G_OLE_DataBlock%!00 = OLE_EndOfData%
  44. ?*  G_OLE_DataBlock%!04 = OLE_EndOfData%
  45. @*  G_OLE_DataBlock%!08 = OLE_EndOfData%
  46. A*  G_OLE_DataBlock%!12 = OLE_EndOfData%
  47.  First check that file to be linked actually exists..
  48. shell_FileExists( file_name$ ) 
  49.  Make space for new OLE data and write new data, terminating OLE data block
  50.  with 'end_of_data' marker words..
  51. JS  G_OLE_DataBlock% = 
  52. shell_HeapBlockExtend( G_OLE_DataBlock%, OLE_RecLength% )
  53. KQ  loc_newrecord%   = G_OLE_DataBlock% + ( G_OLE_NrOfFiles% * OLE_RecLength% )
  54. ME  loc_newrecord%!00 = 
  55. shell_HeapBlockFetch(
  56. ( file_name$ ) + 1 )
  57. NE  loc_newrecord%!04 = 
  58. shell_HeapBlockFetch(
  59. ( user_FN$   ) + 1 )
  60. O)  $( loc_newrecord%!00 ) = file_name$
  61. P'  $( loc_newrecord%!04 ) = user_FN$
  62. QD  loc_newrecord%!08      = 
  63. shell_FileGetDateStamp( file_name$ )
  64. R   loc_newrecord%!12      = 0
  65. T@  !( loc_newrecord% + OLE_RecLength% + 00 ) = OLE_EndOfData%
  66. U@  !( loc_newrecord% + OLE_RecLength% + 04 ) = OLE_EndOfData%
  67. V@  !( loc_newrecord% + OLE_RecLength% + 08 ) = OLE_EndOfData%
  68. W@  !( loc_newrecord% + OLE_RecLength% + 12 ) = OLE_EndOfData%
  69.   G_OLE_NrOfFiles% += 1
  70.  99, "Unable to find file '" + file_name$ + "'"
  71. c *|Stop PROCshell_OLELinkFile
  72. g#*|Start PROCshell_OLEDeLinkFile
  73. shell_OLEDeLinkFile( file_name$ )
  74.  OLE_index%, curr_file_name$
  75. OLE_index%     = 0
  76. shell_FileExists( file_name$ ) 
  77. q:    curr_file_name$ = $( G_OLE_DataBlock%!OLE_index% )
  78. s(    
  79.  curr_file_name$ = file_name$ 
  80. uG      
  81. shell_HeapBlockReturn( G_OLE_DataBlock%!( OLE_index% + 00 ))
  82. vG      
  83. shell_HeapBlockReturn( G_OLE_DataBlock%!( OLE_index% + 04 ))
  84.       fix_ptr% = OLE_index%
  85.       
  86. |c        G_OLE_DataBlock%!( fix_ptr% + 00 ) = G_OLE_DataBlock%!( fix_ptr% + 00 + OLE_RecLength%)
  87. }c        G_OLE_DataBlock%!( fix_ptr% + 04 ) = G_OLE_DataBlock%!( fix_ptr% + 04 + OLE_RecLength%)
  88. ~c        G_OLE_DataBlock%!( fix_ptr% + 08 ) = G_OLE_DataBlock%!( fix_ptr% + 08 + OLE_RecLength%)
  89. c        G_OLE_DataBlock%!( fix_ptr% + 12 ) = G_OLE_DataBlock%!( fix_ptr% + 12 + OLE_RecLength%)
  90. &        fix_ptr% += OLE_RecLength%
  91. 6      
  92.  G_OLE_DataBlock%!fix_ptr% = OLE_EndOfData%
  93.       G_OLE_NrOfFiles% -= 1
  94. Y      G_OLE_DataBlock% = 
  95. shell_HeapBlockExtend( G_OLE_DataBlock%, - OLE_RecLength% )
  96.         
  97. $    OLE_index% += OLE_RecLength%
  98.  G_OLE_DataBlock%!OLE_index% = OLE_EndOfData%
  99. "*|Stop PROCshell_OLEDeLinkFile
  100. !*|Start FNshell_OLEFileStatus
  101. shell_OLEFileStatus( file_name$ )
  102.  *|Stop FNshell_OLEFileStatus
  103. (*|Start PROCshell_OLEScanLinkedFiles
  104. shell_OLEScanLinkedFiles
  105.  OLE_index%,  _file_name$, fn_name$, void%
  106.  new_date_stamp%, old_date_stamp%
  107.  Call a user defined FN if any of the files in the OLE 'watching'
  108.  list have changed their datestamp since the last time they
  109.  were scanned. This routine should be called every 1 or 2 seconds
  110.  by the PollIdle handler of a wimp application.
  111. OLE_index%     = 0
  112. shell_OLEInProgress 
  113.  G_OLE_DataBlock%!OLE_index% <> OLE_EndOfData%
  114. @    
  115.  Note '_file_name$' is used so that crunching the BASIC
  116. >    
  117.  program does not change the name of the variable (as
  118.      
  119.  it is EVALuated later)
  120. 6    _file_name$ = $( G_OLE_DataBlock%!OLE_index% )
  121. =    old_date_stamp% = G_OLE_DataBlock%!( OLE_index% + 8 )
  122. @    new_date_stamp% = 
  123. shell_FileGetDateStamp( _file_name$ )
  124. .    
  125.  new_date_stamp% <> old_date_stamp% 
  126. ?      G_OLE_DataBlock%!( OLE_index% + 8 ) = new_date_stamp%
  127. =      fn_name$ = $( G_OLE_DataBlock%!( OLE_index% + 4 ) )
  128. 9      void% = 
  129. ( "FN" + fn_name$ + "( _file_name$ )")
  130.         
  131. $    OLE_index% += OLE_RecLength%
  132. '*|Stop PROCshell_OLEScanLinkedFiles
  133. )*|Start FNshell_OLEGetNrOfLinkedFiles
  134. shell_OLEGetNrOfLinkedFiles
  135. = G_OLE_NrOfFiles%
  136. (*|Stop FNshell_OLEGetNrOfLinkedFiles
  137. !*|Start FNshell_OLEInProgress
  138. shell_OLEInProgress
  139.  G_OLE_NrOfFiles% > 0 
  140.  *|Stop FNshell_OLEInProgress
  141. #*|Start PROCshell_DoOLEHandling
  142. shell_DoOLEHandling
  143. shell_OLEInProgress 
  144. shell_OLEScanLinkedFiles
  145. "*|Stop PROCshell_DoOLEHandling
  146.